# -*- coding: utf-8 -*-
# @Time    : 2022/5/25 2:11
# @Author  : leijiu
# @Email   : 517711635@qq.com
# @File    : page_goods_class_list.py
# @Software: PyCharm
"""
商品分类列表页面
"""
from selenium.webdriver.common.by import By
from time import sleep
from page.page_base import BasePage   #引入基类

class GoodsClassList(BasePage):

    #添加商品分类定位器
    #点击商品管理定位器
    ele_goodsadmin_locator = (By.CSS_SELECTOR, "#menu-ul > li.collapse.lis.ico_1")
    #商品分类定位器
    ele_goodsclass_locator = (By.LINK_TEXT, "商品分类")
    #添加分类定位器
    ele_addgoodsclass_locator = (By.LINK_TEXT, "添加分类")
    #编辑定位器
    ele_editgoodsclass_locator = (By.LINK_TEXT, "编辑")
    #删除定位器
    ele_deletegoodsclass_locator=(By.XPATH,"/html/body/form/div/table/tbody/tr[2]/td[8]/a[3]")
    #切换到左边页面
    def left_page(self):
        self.driver.switch_to.frame("menu-frame")
        sleep(1)
        # 点击商品管理
    def goods_admin(self):
        self.driver.find_element(*self.ele_goodsadmin_locator).click()
        sleep(1)
        # 点击商品分类
    def goods_class(self):
        self.driver.find_element(*self.ele_goodsclass_locator).click()
        sleep(1)
        # 切换到主页面
    def main_page(self):
        self.driver.switch_to.parent_frame()
        self.driver.switch_to.frame("main-frame")
        sleep(1)
        # 点击添加分类
    def add_goods_class(self):
        self.driver.find_element(*self.ele_addgoodsclass_locator).click()
        # 点击编辑类
    def edit_goods_class(self):
        self.driver.find_element(*self.ele_editgoodsclass_locator).click()
        # 点击删除
    def delete_goods_class(self):
        self.driver.find_element(*self.ele_deletegoodsclass_locator).click()
        sleep(1)
        self.driver.switch_to.alert.accept()

